package com.repair.project.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.repair.project.config.R;
import com.repair.project.entity.Material;
import com.repair.project.entity.Typelist;
import com.repair.project.service.MaterialService;
import com.repair.project.service.TypelistService;
import io.swagger.annotations.ApiOperation;
import net.bytebuddy.description.type.TypeList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hz
 * @since 2021-01-12
 */
@RestController
@RequestMapping("/project/typelist")
public class TypelistController {


    @Autowired
    TypelistService typelistService;

    @ApiOperation("接口描述：获取所有报修类型列表")
    @GetMapping("getTypeList")
    public R getTypeList(){

        List<Typelist> typelists =typelistService.list(null);

        return R.ok().data("datalist",typelists);
    }

    @ApiOperation("接口描述:增加报修类型")
    @PostMapping("addType")
    public R addType(@RequestBody Typelist typelist){
        return R.ok().data("data",typelistService.save(typelist));
    }

    @ApiOperation("接口描述：删除报修类型")
    @GetMapping("DelType")
    public R DelType(@RequestParam(value = "typeid")int typeid){
        return R.ok().data("data",typelistService.removeById(typeid));
    }

    @ApiOperation("接口描述：更新报修类型")
    @PostMapping("updType")
    public R updType(@RequestBody Typelist typelist){
        return R.ok().data("data",typelistService.updateById(typelist));
    }








}

